import base64


class SafeBase64:

    @staticmethod
    def decode(decoded_string: str) -> bytes:
        decoded_string = decoded_string.replace("-", "+").replace("_", "/").replace("~", "=")
        return base64.b64decode(decoded_string)

    @staticmethod
    def encode(encoded_string: bytes) -> str:
        encoded_string = base64.b64encode(encoded_string).decode('utf8')
        encoded_string = encoded_string.replace("+", "-").replace("/", "_").replace("=", "~")
        return encoded_string
